package com.bawei.a2010douyin.annotation;

import android.text.TextUtils;

import com.alibaba.android.arouter.launcher.ARouter;
import com.bawei.a2010douyin.base.utils.ARouterPath;
import com.blankj.utilcode.util.SPUtils;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

@Aspect//切面
public class LoginCheckAspectJ {

    //切面点
    @Pointcut("execution(@com.bawei.a2010douyin.annotation.LoginCheck * *(..))")
    public void LoginCheck(){

    }

    //切面点的处理逻辑
    @Around("LoginCheck()")
    public void LoginChekAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        String token = SPUtils.getInstance().getString("token");
        if(TextUtils.isEmpty(token)){//跳转到登陆页面
            ARouter.getInstance().build(ARouterPath.LOGIN_AROUTER_PATH).navigation();
        }else{
            proceedingJoinPoint.proceed();
        }

    }
}
